StatesMachine

interface StatesMachine<T : State> : StatesHandler<T, T>

Default StatesMachine may startChain and use inside logic for handling States. By default you may use DefaultStatesMachine or build it with dev.inmo.micro_utils.fsm.common.dsl.buildFSM. Implementers MUST NOT start handling until start method will be called

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract suspend fun StatesMachine<in T>.handleState(state: T): T?

Main handling of state. In case when this state leads to another State and handleState returns not null State it is assumed that chain is not completed.

Link copied to clipboard
open suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T?
open suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>, onStateHandlingErrorHandler: StateHandlingErrorHandler<T>): T?
Link copied to clipboard
abstract fun start(scope: CoroutineScope): Job

Starts handling of States

Link copied to clipboard
abstract suspend fun startChain(state: T)

Start chain of States witn state

Inheritors

DefaultStatesMachine
Link copied to clipboard
UpdatableStatesMachine
Link copied to clipboard

Extensions

holder
Link copied to clipboard
inline fun <I : O, O : State> StatesHandler<I, O>.holder(strict: Boolean = true): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(noinline filter: suspend (state: State) -> Boolean): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(strict: Boolean = true): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(noinline filter: suspend (state: State) -> Boolean): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(strict: Boolean = true): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(noinline filter: suspend (state: State) -> Boolean): CustomizableHandlerHolder<O, O>